package com.fqgj.xjd.user.client.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/3
 * Time: 上午10:00
 */
public enum UserMarriageEnum {
    NOT_MARRIED(0, "Single"),
    MARRIED_AND_PROCREATED(1, "Married have children"),
    MARRIED_AND_NOT_PROCREATED(2, "Married without child");

    private Integer type;
    private String desc;

    UserMarriageEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public UserMarriageEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public UserMarriageEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (UserMarriageEnum enumObj : UserMarriageEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static UserMarriageEnum getEnumByType(Integer type) {
        UserMarriageEnum userMarriageEnum = null;
        for (UserMarriageEnum enumObj : UserMarriageEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userMarriageEnum = enumObj;
                break;
            }
        }
        return userMarriageEnum;
    }
    
    public static UserMarriageEnum getEnumByDesc(String desc) {
        UserMarriageEnum userMarriageEnum = null;
        for (UserMarriageEnum enumObj : UserMarriageEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userMarriageEnum = enumObj;
                break;
            }
        }
        return userMarriageEnum;
    }
}
